package cn.wolfcode.mq;

import cn.wolfcode.web.controller.OrderInfoController;
import cn.wolfcode.web.controller.SeckillProductController;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;
/*
    消费者：处理sigeTopic的消息，主要用来修改本服务的本地标识的。
 */
@Component
@RocketMQMessageListener(consumerGroup = "signTopcConsumer",
                        topic = MQConstant.CANCEL_SECKILL_OVER_SIGE_TOPIC,
                        messageModel = MessageModel.BROADCASTING  //考虑到服务集群下，都要修改本地标识，采用广播模式（一个消息被消费多次）.
)
public class OrderResult_SignTopic_Listener implements RocketMQListener<OrderMQResult> {
    @Override
    public void onMessage(OrderMQResult orderMQResult) {
        //修改本地标识:将此秒杀商品的标识设置为false
        OrderInfoController.seckillproductIsSelloutMap.put(orderMQResult.getSeckillId(),false);
    }
}
